/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Busqueda.java
 *
 * Created on 18/11/2011, 08:15:41 PM
 */
package Vista;

import DAO_Modelo.dao.PrestamoDao;
import DAO_Modelo.dao.SocioDao;
import DAO_Modelo.dto.Prestamo;
import DAO_Modelo.dto.Socio;
import DAO_Modelo.exceptions.SocioDaoException;
import DAO_Modelo.factory.PrestamoDaoFactory;
import DAO_Modelo.factory.SocioDaoFactory;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.print.attribute.standard.Sides;
import javax.swing.JOptionPane;

/**
 *
 * @author jose,digberht
 */
public class Busqueda extends javax.swing.JFrame {

    public static int filaSelec;
    Object contenido[][];
    String etiquetas[]=new String [] {
            " ID ", "     Nombre     ", "   Distrito   ","      Direccion      "
        };
        /** 
	 * Constructor de la clase de Busqueda donde se inicializan componentes.
	 */
        Busqueda() {
        initComponents();
        B_Busq_ModReg.setEnabled(false);
        B_Busq_Historia.setEnabled(false);
        B_Busq_EstCue.setEnabled(false);
        B_Busq_EstaDemanda.setEnabled(false);
        B_Busq_SimulCP.setEnabled(true);
        Table_Busq_Resultado.setEnabled(false);
        B_Busq_EstaDemanda.setVisible(false);
        filaSelec=-1;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        Text_Busq_Nombre = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        Text_Busq_Codigo = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        Table_Busq_Resultado = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        B_Busq_EstCue = new javax.swing.JButton();
        B_Busq_Historia = new javax.swing.JButton();
        B_Busq_SaldoPres = new javax.swing.JButton();
        B_Busq_ModReg = new javax.swing.JButton();
        B_Busq_EstaDemanda = new javax.swing.JButton();
        B_Busq_SimulCP = new javax.swing.JButton();
        B_Busq_Buscar = new javax.swing.JButton();
        B_Busq_Cerrar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 400, 200));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Busqueda"));

        jLabel2.setText("Nombre");

        jLabel3.setText("Codigo");

        Table_Busq_Resultado.setModel(new javax.swing.table.DefaultTableModel(
            contenido,
            etiquetas
        ));
        Table_Busq_Resultado.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Table_Busq_ResultadoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(Table_Busq_Resultado);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Opciones"));

        B_Busq_EstCue.setText("Estado de Cuenta");
        B_Busq_EstCue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_EstCueActionPerformed(evt);
            }
        });

        B_Busq_Historia.setText("Historia");
        B_Busq_Historia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_HistoriaActionPerformed(evt);
            }
        });

        B_Busq_SaldoPres.setText("Saldo de Prestamo");
        B_Busq_SaldoPres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_SaldoPresActionPerformed(evt);
            }
        });

        B_Busq_ModReg.setText("Modificar Registro de Socio");
        B_Busq_ModReg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_ModRegActionPerformed(evt);
            }
        });

        B_Busq_EstaDemanda.setText("Estado de Demanda");
        B_Busq_EstaDemanda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_EstaDemandaActionPerformed(evt);
            }
        });

        B_Busq_SimulCP.setText("Simulacion de Calendario de Pagos");
        B_Busq_SimulCP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_SimulCPActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(B_Busq_Historia, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(B_Busq_EstCue, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(B_Busq_ModReg, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(B_Busq_SaldoPres, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(B_Busq_EstaDemanda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(B_Busq_SimulCP, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(B_Busq_ModReg)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(B_Busq_EstCue)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(B_Busq_Historia)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(B_Busq_SaldoPres)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(B_Busq_SimulCP)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(B_Busq_EstaDemanda)
                .addContainerGap())
        );

        B_Busq_Buscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/buscar.JPG"))); // NOI18N
        B_Busq_Buscar.setText("Buscar");
        B_Busq_Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_BuscarActionPerformed(evt);
            }
        });

        B_Busq_Cerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/salisr.JPG"))); // NOI18N
        B_Busq_Cerrar.setText("Cerrar");
        B_Busq_Cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_Busq_CerrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(Text_Busq_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Text_Busq_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(B_Busq_Buscar))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(B_Busq_Cerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(Text_Busq_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(Text_Busq_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(B_Busq_Buscar))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                        .addComponent(B_Busq_Cerrar)))
                .addGap(66, 66, 66))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
        /** 
	 * Funcion de evento del boton Estado de demanda que lanza el frame Estado de Demanda
	 */
private void B_Busq_EstaDemandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_EstaDemandaActionPerformed
// TODO add your handling code here:
    Sigele.estado_demanda= new Estado_Demanda(Table_Busq_Resultado.getSelectedRow());
    Sigele.estado_demanda.setVisible(true);
}//GEN-LAST:event_B_Busq_EstaDemandaActionPerformed
/** 
	 * Funcion de evento del boton de Historial que lanza el frame Historia segun un elemento selleccionado de la lista 
	 */
private void B_Busq_HistoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_HistoriaActionPerformed
// TODO add your handling code here:
    Sigele.historia= new Historias(Integer.parseInt(Table_Busq_Resultado.getValueAt(Table_Busq_Resultado.getSelectedRow(), 0).toString())-1);
    B_Busq_ModReg.setEnabled(false);
    B_Busq_Historia.setEnabled(false);
    B_Busq_EstCue.setEnabled(false);
    Sigele.historia.setVisible(true);
}//GEN-LAST:event_B_Busq_HistoriaActionPerformed
        /** 
	 * Funcion de evento del boton de Simulacion de Calendario de pagos que lanza el frame Simulacion de pagos
	 */
private void B_Busq_SimulCPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_SimulCPActionPerformed
// TODO add your handling code here:
    Sigele.simulacion_pagos.setVisible(true);
}//GEN-LAST:event_B_Busq_SimulCPActionPerformed
    /** 
	 * Funcion de evento del boton de Estado de cuenta que lanza en frame Estado de Cuenta
	 */
private void B_Busq_EstCueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_EstCueActionPerformed
// TODO add your handling code here:
    B_Busq_ModReg.setEnabled(false);
    B_Busq_Historia.setEnabled(false);
    B_Busq_EstCue.setEnabled(false);
    Sigele.estado_cuenta= new EstadoCuenta(Integer.parseInt(Table_Busq_Resultado.getValueAt(Table_Busq_Resultado.getSelectedRow(), 0).toString())-1);
    Sigele.estado_cuenta.setVisible(true);
}//GEN-LAST:event_B_Busq_EstCueActionPerformed
/** 
	 * Funcion de evento del boton de Cerrar que que cierra solo el frame activo 
	 */
private void B_Busq_CerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_CerrarActionPerformed
// TODO add your handling code here:
System.exit(0);
    this.dispose();
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    
}//GEN-LAST:event_B_Busq_CerrarActionPerformed
/** 
	 * Funcion de evento del boton de Buscar que segun un nombre o codigo muestra resultados en una lista
	 */
private void B_Busq_BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_BuscarActionPerformed
// TODO add your handling code here:
   // InputStreamReader lec=new InputStreamReader(__);
    
    if(Text_Busq_Nombre.getText().equals("")&& Text_Busq_Codigo.getText().equals("")){
        Vector <String[]> socios= new Vector<String[]>();
            try {
                Sigele.sociodtoLista = Sigele.socioDao.findAll();
            } catch (SocioDaoException ex) {
                Logger.getLogger(Busqueda.class.getName()).log(Level.SEVERE, null, ex);
            }
        
            for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                String tmp[] = {String.valueOf(Sigele.sociodtoLista[i].getCodigoSocio()), Sigele.sociodtoLista[i].getNombre() + " " + Sigele.sociodtoLista[i].getApellidos(),
                    String.valueOf(Sigele.sociodtoLista[i].getDistrito()), Sigele.sociodtoLista[i].getDireccion()};
                socios.add(i, tmp);
            }
            contenido=new Object[socios.size()][etiquetas.length];
            for (int i = 0; i < socios.size(); i++) {
                   contenido[i]=socios.get(i);
                }
    }else{
        Vector <String[]> socios= new Vector<String[]>();
        String NombreSocio=Text_Busq_Nombre.getText();
        if(NombreSocio.length()>0){
            try {
                if(NombreSocio.contains(" ")){
                   
                    Sigele.sociodtoLista=Sigele.socioDao.findAll();
                    String nom_temp=NombreSocio.split(" ")[0]+NombreSocio.split(" ")[1];
                    Vector<Socio> s=new Vector<Socio>();
                    
                    for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                        Socio socio = Sigele.sociodtoLista[i];
                        String nom_apel=socio.getNombre()+socio.getApellidos().split(" ")[0]+socio.getApellidos().split(" ")[1];
                        
                        if(nom_apel.toLowerCase().contains(nom_temp.toLowerCase())){
                            s.add(socio);
                        }
                    }
                    
                    if (s.size() > 0) {
                        for (int i = 0; i < s.size(); i++) {
                            String tmp[] = {String.valueOf(s.get(i).getCodigoSocio()), s.get(i).getNombre() + " " + s.get(i).getApellidos(),
                                s.get(i).getDistrito(),String.valueOf(s.get(i).getDireccion())};
                            socios.add(i, tmp);
                        }
                    } else {
                        Sigele.sociodtoLista = Sigele.socioDao.findAll();
                        String apel_temp = NombreSocio.split(" ")[0] + NombreSocio.split(" ")[1];
                        Vector<Socio> sss = new Vector<Socio>();

                        for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                            Socio socio = Sigele.sociodtoLista[i];
                            String apel = socio.getApellidos().split(" ")[0] + socio.getApellidos().split(" ")[1];

                            if (apel.toLowerCase().contains(apel_temp.toLowerCase())) {
                                sss.add(socio);
                            }
                        }

                        if (sss.size() > 0) {
                            for (int i = 0; i < sss.size(); i++) {
                                String tmp[] = {String.valueOf(sss.get(i).getCodigoSocio()), sss.get(i).getNombre() + " " + sss.get(i).getApellidos(),
                                    sss.get(i).getDistrito(),sss.get(i).getDireccion()};
                                socios.add(i, tmp);
                            }
                        } else {
                            JOptionPane.showMessageDialog(null, "No se encontro Socio");
                            B_Busq_ModReg.setEnabled(false);
                            B_Busq_Historia.setEnabled(false);
                            B_Busq_EstCue.setEnabled(false);
                        }
                    }
                }else{
                    Sigele.sociodtoLista = Sigele.socioDao.findAll();
                    Vector<Socio> ss = new Vector<Socio>();

                        for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                            Socio socio = Sigele.sociodtoLista[i];
                            String nombre = socio.getNombre();

                            if (nombre.toLowerCase().contains(NombreSocio.toLowerCase())) {
                                ss.add(socio);
                            }
                        }
                    
                    if (ss.size() > 0) {
                        for (int i = 0; i < ss.size(); i++) {
                            String tmp[] = {String.valueOf(ss.get(i).getCodigoSocio()), ss.get(i).getNombre() + " " + ss.get(i).getApellidos(),
                                String.valueOf(ss.get(i).getDistrito()),ss.get(i).getDireccion()};
                            socios.add(i, tmp);
                        }
                    } else {
                        Sigele.sociodtoLista = Sigele.socioDao.findAll();
                        String apel_temp = NombreSocio;
                        Vector<Socio> sss = new Vector<Socio>();

                        for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                            Socio socio = Sigele.sociodtoLista[i];
                            String apel = socio.getApellidos().split(" ")[0] + socio.getApellidos().split(" ")[1];

                            if (apel.toLowerCase().contains(apel_temp.toLowerCase())) {
                                sss.add(socio);
                            }
                        }

                        if (sss.size() > 0) {
                            for (int i = 0; i < sss.size(); i++) {
                                String tmp[] = {String.valueOf(sss.get(i).getCodigoSocio()), sss.get(i).getNombre() + " " + sss.get(i).getApellidos(),
                                    String.valueOf(sss.get(i).getDistrito()),sss.get(i).getDireccion()};
                                socios.add(i, tmp);
                            }
                        } else {
                            JOptionPane.showMessageDialog(null, "No se encontro Socio");
                            B_Busq_ModReg.setEnabled(false);
                            B_Busq_Historia.setEnabled(false);
                            B_Busq_EstCue.setEnabled(false);
                        }
                    }
                }
                
            } catch (SocioDaoException ex) {
                Logger.getLogger(Busqueda.class.getName()).log(Level.SEVERE, null, ex);
            }
            contenido=new Object[socios.size()][etiquetas.length];
            for (int i = 0; i < socios.size(); i++) {
                   contenido[i]=socios.get(i);
                }
            }
    }
    if(Text_Busq_Codigo.getText().equals("")&&Text_Busq_Nombre.getText().equals("")){
        Vector <String[]> socios= new Vector<String[]>();
            try {
                Sigele.sociodtoLista = Sigele.socioDao.findAll();
            } catch (SocioDaoException ex) {
                Logger.getLogger(Busqueda.class.getName()).log(Level.SEVERE, null, ex);
            }
        
            for (int i = 0; i < Sigele.sociodtoLista.length; i++) {
                String tmp[] = {String.valueOf(Sigele.sociodtoLista[i].getCodigoSocio()), Sigele.sociodtoLista[i].getNombre() + " " + Sigele.sociodtoLista[i].getApellidos(),
                    String.valueOf(Sigele.sociodtoLista[i].getDistrito()), Sigele.sociodtoLista[i].getDireccion()};
                socios.add(i, tmp);
            }
            contenido=new Object[socios.size()][etiquetas.length];
            for (int i = 0; i < socios.size(); i++) {
                   contenido[i]=socios.get(i);
                }
        //JOptionPane.showMessageDialog(null, "Ingrese Nombre o Codigo");
    }else{
        
        Text_Busq_Nombre.setText("");
        Vector <String[]> socios= new Vector<String[]>();
        String CodigoSocio = Text_Busq_Codigo.getText();
        if (CodigoSocio.length() > 0) {
            try {
                Sigele.sociodto = Sigele.socioDao.findByPrimaryKey(Integer.valueOf(CodigoSocio));
                if(Sigele.sociodto!=null){
                    Sigele.sociodtoLista = new Socio[]{Sigele.sociodto};
                    for (int i = 0; i < Sigele.sociodtoLista.length; i++) {

                        String tmp[] = {String.valueOf(Sigele.sociodtoLista[i].getCodigoSocio()), Sigele.sociodtoLista[i].getNombre() + " " + Sigele.sociodtoLista[i].getApellidos(),
                            String.valueOf(Sigele.sociodtoLista[i].getDepartamento())};
                        socios.add(i, tmp);
                    }
                }else{
                    JOptionPane.showMessageDialog(null, "No se encontro Socio");
                    B_Busq_ModReg.setEnabled(false);
                    B_Busq_Historia.setEnabled(false);
                    B_Busq_EstCue.setEnabled(false);
                }
            } catch (SocioDaoException ex) {
                Logger.getLogger(Busqueda.class.getName()).log(Level.SEVERE, null, ex);
            }
            contenido = new Object[socios.size()][etiquetas.length];
            for (int i = 0; i < socios.size(); i++) {
                contenido[i] = socios.get(i);
            }
        }
    }
    Table_Busq_Resultado.setModel(new javax.swing.table.DefaultTableModel(contenido, etiquetas));
    Table_Busq_Resultado.setEnabled(true);
     
}//GEN-LAST:event_B_Busq_BuscarActionPerformed
/** 
	 * Habilita los botones al seleccionar una fila de la tabla de resultados
	 */
private void Table_Busq_ResultadoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Table_Busq_ResultadoMouseClicked
// TODO add your handling code here:
    for (int i = 0; i < Table_Busq_Resultado.getRowCount(); i++) {
        if(Table_Busq_Resultado.isRowSelected(i) && Table_Busq_Resultado.getValueAt(i, 0).toString()!=null){
            B_Busq_EstaDemanda.setEnabled(true);
            B_Busq_Historia.setEnabled(true);
            B_Busq_EstCue.setEnabled(true);
            B_Busq_ModReg.setEnabled(true);
            filaSelec=Table_Busq_Resultado.getSelectedRow();
        }
    }
    
}//GEN-LAST:event_Table_Busq_ResultadoMouseClicked
/** 
	 * Funcion de evento del boton de Slado de prestamo que lanza el frame Saldo de Prestamo
	 */
private void B_Busq_SaldoPresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_SaldoPresActionPerformed
// TODO add your handling code here:
    Sigele.saldo_prestamo=new Saldo_Prestamo();
    Sigele.saldo_prestamo.setVisible(true);
}//GEN-LAST:event_B_Busq_SaldoPresActionPerformed

/** 
	 * Funcion de evento del boton de modificar Registrode Socio que lanza en frame de Modificacion de datos
	 */
private void B_Busq_ModRegActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_Busq_ModRegActionPerformed
// TODO add your handling code here:
    Sigele.modif_reg_socio=new Modif_Reg_Socio(Integer.parseInt(Table_Busq_Resultado.getValueAt(Table_Busq_Resultado.getSelectedRow(), 0).toString())-1);
    B_Busq_ModReg.setEnabled(false);
    B_Busq_Historia.setEnabled(false);
    B_Busq_EstCue.setEnabled(false);
    Sigele.modif_reg_socio.setVisible(true);

}//GEN-LAST:event_B_Busq_ModRegActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Busqueda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Busqueda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Busqueda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Busqueda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Busqueda().setVisible(true);
            }
        });
        
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton B_Busq_Buscar;
    private javax.swing.JButton B_Busq_Cerrar;
    private javax.swing.JButton B_Busq_EstCue;
    private javax.swing.JButton B_Busq_EstaDemanda;
    private javax.swing.JButton B_Busq_Historia;
    private javax.swing.JButton B_Busq_ModReg;
    private javax.swing.JButton B_Busq_SaldoPres;
    private javax.swing.JButton B_Busq_SimulCP;
    private javax.swing.JTable Table_Busq_Resultado;
    private javax.swing.JTextField Text_Busq_Codigo;
    private javax.swing.JTextField Text_Busq_Nombre;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
